package com.ruoyi.project.countrybus.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.countrybus.domain.SysStationRoute;
import com.ruoyi.project.countrybus.service.ISysStationRouteService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 路线站点信息Controller
 * 
 * @author yangwenbo
 * @date 2022-04-26
 */
@RestController
@RequestMapping("/countrybus/stationroute")
public class SysStationRouteController extends BaseController
{
    @Autowired
    private ISysStationRouteService sysStationRouteService;

    /**
     * 查询路线站点信息列表
     */
    @PreAuthorize("@ss.hasPermi('countrybus:stationroute:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysStationRoute sysStationRoute)
    {
        startPage();
        List<SysStationRoute> list = sysStationRouteService.selectSysStationRouteList(sysStationRoute);
        return getDataTable(list);
    }

    /**
     * 导出路线站点信息列表
     */
    @PreAuthorize("@ss.hasPermi('countrybus:stationroute:export')")
    @Log(title = "路线站点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysStationRoute sysStationRoute)
    {
        List<SysStationRoute> list = sysStationRouteService.selectSysStationRouteList(sysStationRoute);
        ExcelUtil<SysStationRoute> util = new ExcelUtil<SysStationRoute>(SysStationRoute.class);
        util.exportExcel(response, list, "路线站点信息数据");
    }

    /**
     * 获取路线站点信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('countrybus:stationroute:query')")
    @GetMapping(value = "/{routeId}")
    public AjaxResult getInfo(@PathVariable("routeId") Long routeId)
    {
        return AjaxResult.success(sysStationRouteService.selectSysStationRouteByRouteId(routeId));
    }

    /**
     * 新增路线站点信息
     */
    @PreAuthorize("@ss.hasPermi('countrybus:stationroute:add')")
    @Log(title = "路线站点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysStationRoute sysStationRoute)
    {
        return toAjax(sysStationRouteService.insertSysStationRoute(sysStationRoute));
    }

    /**
     * 修改路线站点信息
     */
    @PreAuthorize("@ss.hasPermi('countrybus:stationroute:edit')")
    @Log(title = "路线站点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysStationRoute sysStationRoute)
    {
        return toAjax(sysStationRouteService.updateSysStationRoute(sysStationRoute));
    }

    /**
     * 删除路线站点信息
     */
    @PreAuthorize("@ss.hasPermi('countrybus:stationroute:remove')")
    @Log(title = "路线站点信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{routeIds}")
    public AjaxResult remove(@PathVariable Long[] routeIds)
    {
        return toAjax(sysStationRouteService.deleteSysStationRouteByRouteIds(routeIds));
    }
}
